
package com.compuvest.web;

public class Address implements java.io.Serializable {

    private String company;
    private String firstName;
    private String lastName;
    private String address1;
    private String address2;
    private String city;
    private String country;
    private String state;
    private String zip;
    private String zip4;
    private String phone;
    private String cell;
    private String fax;

    public Address() {
	this("", "", "", "", "", "", "", "", "", "", "", "", "");
    }

    public Address(String company, String firstName, String lastName, String address1, String address2, String city, String country, String state, String zip, String zip4, String phone, String cell, String fax) {
	this.company = company;
	this.firstName = firstName;
	this.lastName = lastName;
	this.address1 = address1;
	this.address2 = address2;
	this.city = city;
	this.country = country;
	this.state = state;
	this.zip = zip;
	this.zip4 = zip4;
	this.phone = phone;
	this.cell = cell;
	this.fax = fax;
    }

    public String getFirstName()		{ return firstName; }
    public boolean hasFirstName()		{ return firstName.length() != 0; } // true if not empty
    public void setFirstName(String firstName)	{ this.firstName = defaultValue(firstName); }

    public String getLastName()			{ return lastName; }
    public boolean hasLastName()		{ return lastName.length() != 0; }
    public void setLastName(String lastName)	{ this.lastName = defaultValue(lastName); }

    public String getName()			{ return firstName + " " + lastName; }

    public String getCompany()			{ return company; }
    public void setCompany(String company)	{ this.company = defaultValue(company); }

    public String getAddress1()			{ return address1; }
    public boolean hasAddress1()		{ return address1.length() != 0; }
    public void setAddress1(String address1)	{ this.address1 = defaultValue(address1); }

    public String getAddress2()			{ return address2; }
    public void setAddress2(String address2)	{ this.address2 = defaultValue(address2); }

    public String getCity()			{ return city; }
    public boolean hasCity()			{ return city.length() != 0; }
    public void setCity(String city)		{ this.city = defaultValue(city); }

    public String getState()			{ return state; }
    public boolean hasState()			{ return state.length() != 0; }
    public void setState(String state)		{ this.state = defaultValue(state); }

    public String getCountry()			{ return country; }
    public boolean hasCountry()			{ return country.length() != 0; }
    public void setCountry(String country)	{ this.country = defaultValue(country); }

    public String getZip()			{ return zip; }
    public boolean hasZip()			{ return zip.length() != 0; }
    public void setZip(String zip)		{ this.zip = defaultValue(zip); }

    public String getZip4()			{ return zip4; }
    public void setZip4(String zip4)		{ this.zip4 = defaultValue(zip4); }

    public String getPhone()			{ return phone; }
    public boolean hasPhone()			{ return phone.length() != 0; }
    public void setPhone(String phone)		{ this.phone = defaultValue(phone); }

    public String getCell()			{ return cell; }
    public boolean hasCell()			{ return cell.length() != 0; }
    public void setCell(String cell)		{ this.cell = defaultValue(cell); }

    public String getFax()			{ return fax; }
    public boolean hasFax()			{ return fax.length() != 0; }
    public void setFax(String fax)		{ this.fax = defaultValue(fax); }

    private String defaultValue(String value)	{ return value == null ? "" : value.trim(); }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();

        sb.append("\n\tfirstName: ").append(firstName);
        sb.append("\n\tlastName:  ").append(lastName);
        sb.append("\n\tfull name: ").append(firstName).append(" ").append(lastName);
        sb.append("\n\tcompany:   ").append(company);
        sb.append("\n\taddress1:  ").append(address1);
        sb.append("\n\taddress2:  ").append(address2);
        sb.append("\n\tcity:      ").append(city);
        sb.append("\n\tstate:     ").append(state);
        sb.append("\n\tcountry:   ").append(country);
        sb.append("\n\tzip:       ").append(zip);
        sb.append("\n\tzip4:      ").append(zip4);
        sb.append("\n\tphone:     ").append(phone);
        sb.append("\n\tcell:      ").append(cell);
        sb.append("\n\tfax:       ").append(fax);

        return sb.toString();
    }
}
